package com.itboye.lottery.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.itboye.bylibrary.widget.glide.GlideUtil;
import com.itboye.lottery.R;
import com.itboye.lottery.bean.LotteryClassificationBean;

import java.util.List;

/**
 * Created by wu on 2018/1/9.
 */

public class FootballJinCaiAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private Context context;
//    private List<LotteryClassificationBean> list;
//    private int type;
//
//    public FootballJinCaiAdapter(List<LotteryClassificationBean> list) {
//        this.list = list;
//    }

    public OnItemClickListener itemClickListener;

    public void setOnItemClickListener(FootballJinCaiAdapter.OnItemClickListener itemClickListener) {
        this.itemClickListener = itemClickListener;
    }

//    public void setType(int type) {
//        this.type = type;
//    }

    public interface OnItemClickListener {
        void onItemClick(View view, int position);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();
        View v = LayoutInflater.from(context).inflate(R.layout.item_football, parent, false);
        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
//        GlideUtil.display(context, Integer.parseInt(list.get(position).getImg_url()), holder.img, true);
//        holder.name.setText(list.get(position).getClassification_name());
    }

    @Override
    public int getItemCount() {
        return 6;
//        return list == null ? 0 : list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        public ImageView img;
        public TextView name;

        public ViewHolder(View itemView) {
            super(itemView);
//            img = itemView.findViewById(R.id.img);
//            name = itemView.findViewById(R.id.name);

            itemView.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {
            if (itemClickListener != null) {
                itemClickListener.onItemClick(v, getAdapterPosition());
            }
        }
    }
}
